/* Copyright 2009
 *
 * This program and the accompanying materials
 * are made available under the terms of the
 * Eclipse Public License v1.0 which accompanies
 * this distribution, and is available at
 *
 * 		http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * Contributors:
 * 	   IBM Corporation - initial API and implementation for JDT/DLTK
 *     Sean W. Quinn - initial adoption for use with PHP from various sources.
 */
package org.eclipse.php.internal.ui.preferences.formatter.controller;

/**
 * @author Sean W. Quinn (swquinn@gmail.com)
 *
 */
public class ButtonController {// implements Observer, SelectionListener {
//
//  public ButtonController() {
//    fProfileManager.addObserver(this);
//    fNewButton.addSelectionListener(this);
//    fEditButton.addSelectionListener(this);
//    fDeleteButton.addSelectionListener(this);
//    fLoadButton.addSelectionListener(this);
//    update(fProfileManager, null);
//  }
//
//  public void update(Observable o, Object arg) {
//    Profile selected = ((ProfileManager) o).getSelected();
//    final boolean notBuiltIn = !selected.isBuiltInProfile();
//    fDeleteButton.setEnabled(notBuiltIn);
//  }
//
//  public void widgetSelected(SelectionEvent e) {
//    final Button button = (Button) e.widget;
//    if (button == fEditButton)
//      modifyButtonPressed();
//    else if (button == fDeleteButton)
//      deleteButtonPressed();
//    else if (button == fNewButton)
//      newButtonPressed();
//    else if (button == fLoadButton)
//      loadButtonPressed();
//  }
//
//  public void widgetDefaultSelected(SelectionEvent e) {
//  }
//
//  private void modifyButtonPressed() {
//    final StatusDialog modifyDialog = createModifyDialog(fComposite.getShell(), fProfileManager.getSelected(),
//        fProfileManager, fProfileStore, false);
//    modifyDialog.open();
//  }
//
//  private void deleteButtonPressed() {
//    if (MessageDialog.openQuestion(fComposite.getShell(),
//        PHPFormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title, Messages.format(
//            PHPFormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question, fProfileManager
//                .getSelected().getName()))) {
//      fProfileManager.deleteSelected();
//    }
//  }
//
//  private void newButtonPressed() {
//    final CreateProfileDialog p = new CreateProfileDialog(fComposite.getShell(), fProfileManager, fProfileVersioner);
//    if (p.open() != Window.OK)
//      return;
//    if (!p.openEditDialog())
//      return;
//    final StatusDialog modifyDialog = createModifyDialog(fComposite.getShell(), p.getCreatedProfile(),
//        fProfileManager, fProfileStore, true);
//    modifyDialog.open();
//  }
//
//  private void loadButtonPressed() {
//    final FileDialog dialog = new FileDialog(fComposite.getShell(), SWT.OPEN);
//    dialog.setText(PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title);
//    dialog.setFilterExtensions(new String[] { "*.xml" }); //$NON-NLS-1$
//    final String lastPath = JavaPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$NON-NLS-1$
//    if (lastPath != null) {
//      dialog.setFilterPath(lastPath);
//    }
//    final String path = dialog.open();
//    if (path == null)
//      return;
//    JavaPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
//
//    final File file = new File(path);
//    Collection profiles = null;
//    try {
//      profiles = fProfileStore.readProfilesFromFile(file);
//    }
//    catch (CoreException e) {
//      final String title = PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
//      final String message = PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message;
//      ExceptionHandler.handle(e, fComposite.getShell(), title, message);
//    }
//    if (profiles == null || profiles.isEmpty())
//      return;
//
//    final CustomProfile profile = (CustomProfile) profiles.iterator().next();
//
//    if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) {
//      final String title = PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title;
//      final String message = Messages.format(
//          PHPFormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] {
//              fProfileVersioner.getProfileKind(), profile.getKind() });
//      MessageDialog.openError(fComposite.getShell(), title, message);
//      return;
//    }
//
//    if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) {
//      final String title = PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title;
//      final String message = PHPFormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message;
//      MessageDialog.openWarning(fComposite.getShell(), title, message);
//    }
//
//    if (fProfileManager.containsName(profile.getName())) {
//      final AlreadyExistsDialog aeDialog = new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager);
//      if (aeDialog.open() != Window.OK)
//        return;
//    }
//    fProfileVersioner.update(profile);
//    fProfileManager.addProfile(profile);
//  }
}
